<!DOCTYPE html>
<html lang="en">
<head>
    <title id='Description'>This example shows how to create a Grid from Observable Array data.</title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" />
    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxtagcloud.js"></script>
    <script type="text/javascript" src="../sampledata/generatedata.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var data = generatedata(50);
            var source =
            {
                datatype: "array",
                localdata: data,
                datafields: [
                    { name: 'productname' },
                    { name: 'price' }
                ]
            };
            var dataAdapter = new $.jqx.dataAdapter(source, {});
            $('#tagCloud').jqxTagCloud({
                width: '600px',
                source: dataAdapter,
                fontSizeUnit: 'px',
                minFontSize: 12,
                maxFontSize: 20,
                displayMember: 'productname',
                valueMember: 'price',
                urlBase: 'http://localhost/',
                minColor: '#00AA99',
                maxColor: '#FF0000'
            });

            $("#addItem").jqxButton();
            $("#deleteItem").jqxButton();
            $("#updateItem").jqxButton();
            $("#addItem").click(function () {
                var row = generatedata(1)[0];
                $('#tagCloud').jqxTagCloud('insertAt', 0, row);
            });
            $("#deleteItem").click(function () {
                $('#tagCloud').jqxTagCloud('removeAt', 0);
            });
            $("#updateItem").click(function () {
                var row = generatedata(1)[0];
                $('#tagCloud').jqxTagCloud('updateAt', 0, row);
            });
        });
    </script>
</head>
<body class='default'>
    This demo demonstrates how to add a tag in first position or update/remove the tag in first position.
    <div id="tagCloud"></div>
    <br />
    <br />
    <button id="addItem">Add Item</button>
    <button id="deleteItem">Delete First Item</button>
    <button id="updateItem">Update First Item</button>
    <br />
    <div id="log"></div>
</body>
</html>
